package pacman.entries.pacman.meta_graph;

import pacman.game.Game;

public class MetaGraphEdge implements IMetaGraphObject{

	private MetaGraphNode m_Node1;
	private MetaGraphNode m_Node2;

	public MetaGraphNode getNode1() { return m_Node1; }
	public MetaGraphNode getNode2() { return m_Node2; }

	public MetaGraphNode getOppositeNodeOf(MetaGraphNode node) { 
		
		if (m_Node1.equals(node))
			return m_Node2;
		else if (m_Node2.equals(node))
			return m_Node1;
			
		return null;
	}
	
	public MetaGraphEdge(MetaGraphNode node1, MetaGraphNode node2) {
		if (node1 == null)
			throw new IllegalArgumentException("Argument node1 cannot be null.");
		if (node2 == null)
			throw new IllegalArgumentException("Argument node2 cannot be null.");
		
		m_Node1 = node1;
		m_Node2 = node2;
		m_PillCount = 0;
	}
	
	@Override
	public float calcScore(Game game, MetaGraphEvaluator evaluator) {
		
		return evaluator.Evaluate(game, this);
	}
	
	// ____________________________________________
	private int m_PillCount;
	
	public MetaGraphNode[] getNodes() {
		return new MetaGraphNode[]{m_Node1, m_Node2};
	}
	
	public int getPillCount() {
		return m_PillCount;
	}
	
	public void setPillCount(int count) {
		m_PillCount = count;
	}
	
	public int decrementPillCount() {
		if (m_PillCount == 0)
			return 0;
		return --m_PillCount;
	}

}
